package com.boang.controller;

import com.boang.po.Address;
import com.boang.result.Result;
import com.boang.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hxao
 * @since 2025-02-14
 */
@RestController
@RequestMapping("/address")
public class AddressController {
    @Autowired
    private IAddressService addressService;

    @PostMapping("/add")
    public Result save(Address address) {
        addressService.save(address);
        return Result.success();
    }

    @PutMapping("/update")
    public Result update(Address address) {
        addressService.updateById(address);
        return Result.success();
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id) {
        addressService.removeById(id);
        return Result.success();
    }

    @GetMapping("/get/{id}")
    public Result get(@PathVariable Long id) {
        Address address = addressService.getById(id);
        return Result.success(address);
    }

}
